import pandas as pd
from pathlib import Path


def main() -> None:
    root = Path(__file__).resolve().parents[1]
    src = root / "data_external" / "broadband_country_year_worldbank.csv"
    dst = root / "data_external" / "broadband_country_year.csv"

    df = pd.read_csv(src)
    out = pd.DataFrame(
        {
            "cntry": df["cntry"],
            "year": df["year"],
            "fixed_broadband_per100": df.get("fixed_broadband_per100"),
            "mobile_broadband_per100": pd.NA,
            "internet_users_pct": df.get("internet_users_pct"),
            "source": "World Bank API (WDI)",
            "notes": "Filled from broadband_country_year_worldbank.csv; mobile_broadband_per100 left empty.",
        }
    )
    out.to_csv(dst, index=False, encoding="utf-8")
    print(f"Wrote: {dst} rows={len(out)}")


if __name__ == "__main__":
    main()

